# $Id: PKGBUILD 78215 2012-10-17 10:25:26Z allan $
# Maintainer: Angel Velasquez <angvp@archlinux.org> 
# Contributor: Kaiting Chen <kaitocracy@gmail.com>
# Contributor: Douglas Soares de Andrade <dsa@aur.archlinux.org>
# Contributor: Armando M. Baratti <amblistas@ajato.com.br>
# Contributor: Florian Richter <Florian_Richter@gmx.de>
pkgname=('python-cherrypy' 'python2-cherrypy')
pkgver=3.2.2
pkgrel=2
pkgdesc="A pythonic, object-oriented web development framework"
arch=('any')
url="http://www.cherrypy.org"
license=('BSD')
makedepends=('python' 'python2')
source=("http://download.cherrypy.org/cherrypy/${pkgver}/CherryPy-${pkgver}.tar.gz" cherrypy-python33.patch)
md5sums=('c1b1e9577f65f9bb88bfd1b15b93b911'
         '2fbec41d41c721beaf386ccd5f64c962')

build() {
  (cd "${srcdir}/CherryPy-${pkgver}"; patch -p1 -i "${srcdir}/cherrypy-python33.patch")
  cp -r CherryPy-${pkgver} CherryPy2-${pkgver}

  cd CherryPy-${pkgver}
  python ./setup.py build

  cd "${srcdir}/CherryPy2-${pkgver}"
  sed \
    -e 's_#! /usr/bin/env python_&2_' \
    -i cherrypy/cherryd
  sed \
    -e 's_#!/usr/bin/python_&2_' \
    -i cherrypy/test/sessiondemo.py
  python2 ./setup.py build

}

package_python-cherrypy() {
  depends=('python')

  cd CherryPy-${pkgver}

  python ./setup.py install --root="${pkgdir}" --optimize=1

  install -Dm644 cherrypy/LICENSE.txt \
    "${pkgdir}/usr/share/licenses/python-cherrypy/LICENSE.txt"
}

package_python2-cherrypy() {
  depends=('python2')

  cd CherryPy2-${pkgver}

  python2 ./setup.py install --root="${pkgdir}" --optimize=1
  mv "${pkgdir}/usr/bin/cherryd" "${pkgdir}/usr/bin/cherryd2"

  install -Dm644 cherrypy/LICENSE.txt \
    "${pkgdir}/usr/share/licenses/python2-cherrypy/LICENSE.txt"
}
